# -*- coding: utf-8 -*-
# @时间：2023/11/2 19:53
# @作者：CJiaの可乐哥
# @文件名：api
# @软件：Pycharm2023
from utils.cj_auth import GlobalAuth
from utils.cj_ninja import CjNinjaAPI

from system.router.router_v1 import system_router_v1

api_v1 = CjNinjaAPI(auth=GlobalAuth(), version="1.0.0")


# 统一处理server异常
@api_v1.exception_handler(Exception)
def a(request, exc):
    if hasattr(exc, 'errno'):
        return api_v1.create_response(request, data=[], msg=str(exc), code=exc.errno)
    else:
        return api_v1.create_response(request, data=[], msg=str(exc), code=500)


api_v1.add_router("/system/", system_router_v1)
